<extend name="Public/base" />

<block name="body">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>
    <div class="cf">
        筛选:
            <form action="{:U('index')}" method="POST">
                <input type="text" name="amazon_order_id" class="text input-2x" value="{$amazon_order_id}" placeholder="亚马逊订单号" /> &nbsp; &nbsp; 
                购买日期：<input type="text" name="start_date" class="select_date text input-2x" value="{$start_date}" placeholder="开始时间" />-
                <input type="text" name="end_date" class="select_date text input-2x" value="{$end_date}" placeholder="结束时间" />
                <button class="btn">搜索</button>
            </form>
            <br/>
            <hr>
            获取订单:
            <br/>
            购买日期：<input type="text" class="select_date text input-2x" id="date1" placeholder="开始时间" />-
            <input type="text"  class="select_date text input-2x" id="date2" placeholder="结束时间" />
            <a class="btn" id="getOrder" href="javascript:;">获 取</a>
            <!--            <button class="btn ajax-post confirm" url="{:U('changeStatus?method=deleteUser')}" target-form="ids">删 除</button>-->

        <!--<br/>-->
        <!-- 高级搜索 -->
        <div class="search-form fl cf">
            
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
                <tr>
                    <th class="row-selected row-selected"><input class="check-all" type="checkbox" style="display:none;"/></th>
                    <th class="">amazon订单ID</th>
                    <th class="">SKU</th>
                    <th class="">购买人</th>
                    <th class="">购买数量</th>
                    <th class="">已发数量</th>
                    <th class="">未发数量</th>
                    <th class="">订单金额</th>
                    <th class="">运费金额</th>
                    <th class="">订单状态</th>
                    <th class="">配送方式</th>
                    <th class="">购买日期</th>
                    <th class="">最后更新日期</th>
                    <th class="">操作</th>
                </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
                        <td>{$vo.amazon_order_id} </td>
                        <td>{$vo.seller_sku}</td>
                        <td>{$vo.buyer_name}</td>
                        <td>{$vo.number_of_items_shipped}</td>
                        <td>{$vo.quantity_ordered}</td>
                        <td>{$vo.number_of_items_unshipped}</td>
                        <td>{$vo.order_total}</td>
                        <td>{$vo.shipping_price}</td>
                        <td>{$vo.order_status}</td>
                        <td>{$vo.fulfillment_channel}</td>
                        <td>{$vo.purchase_date}</td>
                        <td>{$vo.last_update_date}</td>
                        <td><a href="{:U('info',array('id'=>$vo['amazon_order_id']))}">查看</a></td>
                    </tr>
                </volist>
                <else/>
                <td colspan="20" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        
        $("#getOrder").click(function(){
            var date1 = $('#date1').val();
            var date2 = $('#date2').val();
            
             $.post("{:U('MwsOrder/getMwsOrder')}", {start_time: date1, end_time: date2}, function (res) {
                    if(res.status==1){
                        alert(res.msg);
                    }
                });
        });
        
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮
        highlight_subnav("{:U('AmazonOrder/index')}");

        $('.select_date').datetimepicker({
            format: 'yyyy-mm-dd',
            language: "zh-CN",
            minView: 2,
            autoclose: true
        });

    </script>
</block>
